package clids.ex1.data_structures;

import java.util.LinkedList;

/**
 * 
 * An implementation of a Linked List data structure,
 * that can store strings.
 * 
 * 
 * @author Ori Miller
 * 
 */
public class MyLinkedList {

	private LinkedList<String> list;

	/**
	 * A default constructor. 
	 * Constructs a new, empty linked list of strings.
	 */
	public MyLinkedList() {
		list = new LinkedList<String>();
	}
	
	
	/**
	 * Adds the specified element to the end of this list.
	 * 
	 * @param s - element to be appended to this list.
	 * 
	 * @return true.
	 */
	public boolean add(String s) {

		boolean ret = list.add(s);
		return ret;
	}

	/**
	 * Removes the first occurrence of the specified element from this list, 
	 * if it is present. 
	 * 
	 * @param s - element to be removed from this list, if present.
	 * 
	 * @return true iff this list contained the specified element.
	 */
	public boolean remove(String s) {
		
		boolean ret = list.remove(s);
		return ret;
	}
	

	/**
	 * 
	 * Looks for the specified element in this list.
	 * 
	 * @param s - element to search for.
	 * 
	 * @return true iff this list contains the specified element.
	 */
	public boolean contains(String s) {
		
		boolean ret = list.contains(s);
		return ret;
	}
	
	/**
	 * 
	 * Returns the element at the specified position in this list.
	 * 
	 * @param index - index of the element to return.
	 * 
	 * @return the element at the specified position in this list.
	 */
	public String get(int index) {
		return list.get(index);
	}

	/**
	 * 
	 * Returns the number of elements in this list.
	 * 
	 * @return the size of this list.
	 */
	public int size() {
		return list.size();
	}
	
} //end of class.
